<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%@ include file="/common/common.jsp" %>

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
  <head>
    
    <title>交费情况</title>
    
	<meta http-equiv="pragma" content="no-cache">
	<meta http-equiv="cache-control" content="no-cache">
	<meta http-equiv="expires" content="0">    
	<meta http-equiv="keywords" content="交费,情况">
	<meta http-equiv="description" content="This is my page">

	<script type="text/javascript" src="${CONTEXT_PATH}/common/js/divTip.js"></script>
	<script src='${CONTEXT_PATH}/dwr/interface/listTipService.js'></script>
	<script src='${CONTEXT_PATH}/dwr/engine.js'></script>
	<script src='${CONTEXT_PATH}/dwr/util.js'></script>

  </head>
  
  <body>
    <center>
    	<s:form name="frm" id="frm" method="post" action="tuitionManage.action" namespace="/inner/charge">
    		<jsp:include page="/jsp/outward/business/common/menuLink.jsp">
    			<jsp:param name="menuLink" value="[{'name':'费用管理'},{'name':'交费情况'}]"/>
    			<jsp:param name="width" value="40%"/>
    		</jsp:include>
    		
    		<s:hidden name="kindergartenId" id="kindergartenId"></s:hidden>
    		<s:hidden name="child.id" id="childId"></s:hidden>
    		<s:hidden name="searchType" id="searchType"></s:hidden>
    		
    		<table cellspacing="1" width="100%" bgcolor="#CCCCCC">
				<tr bgcolor="#FFFFFF" height="26">
					<td align="right" width="10%" class="label">
						交费编号：
					</td>
					<td align="left" width="23%">
						<s:textfield name="tvo.tuition.tuitionNo" id="tuitionNo" cssStyle="width:80%" cssClass="search"></s:textfield>
					</td>
					<td align="right" width="10%" class="label">
						交费日期：
					</td>
					<td align="left" width="23%">
						<s:textfield name="tvo.payDateStart" id="payDateStart" cssStyle="width:100px" cssClass="WDate search" onfocus="WdatePicker({dateFmt:'yyyy-MM-dd'})"></s:textfield>
						-
						<s:textfield name="tvo.payDateEnd" id="payDateEnd" cssStyle="width:100px" cssClass="WDate search" onfocus="WdatePicker({dateFmt:'yyyy-MM-dd'})"></s:textfield>
					</td>
					<td align="right" width="10%" class="label">
						学童编号：
					</td>
					<td align="left" width="24%">
						<s:textfield name="tvo.childNum" id="childNum" cssStyle="width:80%" cssClass="search"></s:textfield>
					</td>
				</tr>
				<tr bgcolor="#FFFFFF" height="26">
					<td align="right" class="label">
						学童姓名：
					</td>
					<td align="left">
						<s:textfield name="tvo.childName" id="childName" cssStyle="width:80%" cssClass="search" onkeyup="childNameTip()"></s:textfield>
					</td>
					<td align="right" class="label">
						金额：
					</td>
					<td align="left">
						<s:textfield name="tvo.totalAmountStart" id="totalAmountStart" cssStyle="width:100px" cssClass="search"></s:textfield>
						-
						<s:textfield name="tvo.totalAmountEnd" id="totalAmountEnd" cssStyle="width:100px" cssClass="search"></s:textfield>
					</td>
					<td align="right" class="label">
						所属班级：
					</td>
					<td align="left">
						<s:select name="tvo.classId" id="classId" value="%{tvo.classId}" list="classList" listKey="id" listValue="className" headerKey="" headerValue="--请选择--" cssStyle="width:120px" cssClass="search"></s:select>
					</td>
				</tr>
			</table>
    		
    		<table cellspacing="0" width="100%">
				<tr>
					<td align="left">
						<input type="button" value="查询" class="btn" onclick="searchThis()"/>
						<my:hasPermission privilegeId="toAddTuition">
						<input type="button" value="新增" class="btn" onclick="toAddTuition()"/>
						</my:hasPermission>
						<input type="button" value="重置" class="btn" onclick="resetSearch()"/>
						&nbsp;<font color="red">请点击“查询”列出交费记录</font>
					</td>
				</tr>
			</table>
			
    		<table width="100%" cellspacing="1" cellpadding="3" bgcolor="#CCCCCC">
    			<tr class="tableHead" align="center">
    				<td width="8%">
    					序号
    				</td>
    				<td width="14%">
    					交费编号
    				</td>
    				<td width="12%">
    					交费日期
    				</td>
    				<td width="18%">
    					保教费、伙食费备注
    				</td>
    				<td width="12%">
    					学童姓名
    				</td>
    				<td width="12%">
    					所属班级
    				</td>
    				<td width="10%">
    					金额
    				</td>
    				<td width="14%">
    					操作
    				</td>
    			</tr>
    			<s:iterator value="lp.list" status="s">
    				<tr align="center"
    					<s:if test="#s.index%2==0">class="tableRow2" onMouseMove="this.className='tableRow3'" onMouseOut="this.className='tableRow2'"</s:if>
						<s:else>class="tableRow1" onMouseMove="this.className='tableRow3'" onMouseOut="this.className='tableRow1'"</s:else>
    				>
    					<td>
    						<s:property value="(pager.thisPage - 1) * pager.pageSize + #s.index + 1" />
    					</td>
    					<td>
    						<s:property value="tuitionNo"/>
    					</td>
    					<td>
    						<s:date name="payDate" format="yyyy-MM-dd"/>
    					</td>
    					<td>
    						<s:property value="remark"/>
    					</td>
    					<td>
    						<s:property value="childName"/>
    					</td>
    					<td>
    						<s:property value="className"/>
    					</td>
    					<td>
    						<s:property value="intAmount"/>
    					</td>
    					<td>
    						<a href="javascript:toUpdateTuition('<s:property value="id" />')"><s:property value="operateChn" /></a>
    						<my:hasPermission privilegeId="delTuition">
    						<a href="javascript:delTuition('<s:property value="id" />')">删除</a>
    						</my:hasPermission>
    					</td>
    				</tr>
    			</s:iterator>
    			<jsp:include page="/common/pager/pager.jsp">
					<jsp:param name="formName" value="frm" />
					<jsp:param name="id" value="1" />
				</jsp:include>
    		</table>
    	</s:form>
    </center>
    
    <script type="text/javascript">
    function toAddTuition()
    {
    	var childId = $('#childId');
    	var kgId = getTopKg();
    	if(isNotNull(childId.val()))
    	{
    		tempSelect(kgId, childId.val());
    	}
    	else
    	{
    		var child = selectOneChild(kgId);
	    	if(child != null)
	    	{
	    		tempSelect(kgId, child.id);
	    	}
    	}
    }
    
    function tempSelect(kgId, cId)
    {
    	var obj = selectOneChargeTemp(kgId, cId);
   		if(obj != null)
   		{
   			if('temp' == obj.type)
   			{
   				var url = realPath + '/inner/charge/toAddTuition.action?kindergartenId=' + kgId + '&tuition.child.id=' + cId + '&ct.id=' + obj.id;
   				window.location.href = url;
   			}
   			else if('manual' == obj.type)
   			{
   				var url = realPath + '/inner/charge/toAddTuitionManual.action?kindergartenId=' + kgId + '&tuition.child.id=' + cId;
   				window.location.href = url;
   			}
   		}
    }
    
    function toUpdateTuition(id)
    {
    	var kgId = getTopKg();
    	var url = realPath + '/inner/charge/toUpdateTuition.action?tuition.id=' + id + '&kindergartenId=' + kgId;
    	window.location.href = url;
    }
    
    function delTuition(id)
    {
    	showConfirm('确认删除？', function(v){
    		if(v == true)
    		{
    			var url = 'inner/charge/delTuition.action?tuition.id=' + id;
    			ajaxAction(url, 'post', 'frm', false, function(){
	    			searchThis();
		    	});
    		}
    	});
    }
    
    function searchThis()
    {
    	if(searchCheck() == false)
    	{
    		return;
    	}
    	$('#thisPage').val(1);
    	$('#searchType').val('immediate');
    	$('#frm').submit();
    }
    
    function childNameTip()
    {
    	var childName = $('#childName');
    	var kgId = getTopKg();
    	showListTip('childName', 'child', 'childName', " and kgId = '" + kgId + "'", childName.width(), 20);
    }
    
    function searchCheck()
    {
    	var totalAmountStart = $('#totalAmountStart');
    	var totalAmountEnd = $('#totalAmountEnd');
    	if(isNotNull(totalAmountStart.val()) && checkFloat(totalAmountStart) == false)
    	{
    		showMsg('开始金额有误。', function(){totalAmountStart.focus();});
    		return false;
    	}
    	if(isNotNull(totalAmountEnd.val()) && checkFloat(totalAmountEnd) == false)
    	{
    		showMsg('结束金额有误。', function(){totalAmountEnd.focus();});
    		return false;
    	}
    	return true;
    }
    </script>
  </body>
</html>
